<template>
	<a-card :bordered="false" :body-style="{ 'padding-bottom': '0px' }" class="mb-2">
		<a-form ref="formRef" name="advanced_search" :model="searchFormState" class="ant-advanced-search-form">
			<a-row :gutter="24">
				<a-col :span="8">
					<a-form-item label="名称关键词" name="searchKey">
						<a-input
							v-model:value="searchFormState.searchKey"
							placeholder="请输入物料商品名称关键词"
							@keyup.enter="table.refresh(true)"
						></a-input>
					</a-form-item>
				</a-col>
				<a-col :span="8">
					<a-button type="primary" @click="table.refresh(true)">查询</a-button>
					<a-button style="margin: 0 8px" @click="() => formRef.resetFields()">重置</a-button>
				</a-col>
			</a-row>
		</a-form>
	</a-card>
	<a-card :bordered="false">
		<s-table
			ref="table"
			table-id="SYS_WAREHOUSE_TABLE"
			:columns="columns"
			:data="loadData"
			:alert="options.alert.show"
			bordered
			:row-key="(record) => record.id"
			:tool-config="toolConfig"
			:row-selection="options.rowSelection"
		>

		</s-table>
  
	</a-card>

</template>

<script setup name="warehouse">
	import { message } from 'ant-design-vue'
  import warehouseapi  from '@/api/wms/warehouse/warehouseapi'
	let searchFormState = reactive({})
	const formRef = ref()
	const table = ref()
	let form = ref()
  
	const toolConfig = { refresh: true, height: true, columnSetting: true, striped: false }
	const columns = [
		{
			title: '仓库',
			dataIndex: 'warehousename',
		},
    {
			title: '商品名称',
			dataIndex: 'productname',
		},
    {
			title: '单价',
			dataIndex: 'price',
		},
		{
			title: '入库数量',
			dataIndex: 'instoreqty',
		},
		{
			title: '当前库存',
			dataIndex: 'inventoryqty',
		},
		{
			title: '规格',
			dataIndex: 'specification',
		},
	]



	let selectedRowKeys = ref([])
	// 列表选择配置
	const options = reactive({
		alert: {
			show: true, //显示选择多少个
			clear: () => {
				selectedRowKeys = ref([])
			}
		},
		rowSelection: {
			onChange: (selectedRowKey, selectedRows) => {
				selectedRowKeys.value = selectedRowKey
			}
		}
	})


	const loadData = (parameter) => {
	 return warehouseapi.getInventoryWarring({parameter}).then(res=>{
      return res
    })
	}



</script>
